<template>
  <view>
  <!-- <view>
    额鹅鹅鹅
  </view> -->
    <u-popup :show="showPopVisible" :round="5" mode="bottom" height="420" @close="closePop">
    <RegisterPop
      :page-type="type"
      :callback-url="callbackUrl"
      :url-params="urlParams"
      :branch-data="registParams"
      @closePopFn="closePop"
      @getphonenumber="getPhoneNumber"
    />
  </u-popup>
  </view>
</template>

<script>
import { getAuthCode } from '@/utils/login';
 import RegisterPop from '@/components/register-pop';
export default {
    name: 'questionnaireSurvey',
    components: {
    RegisterPop
  },
  data() {
    return {
      newUrl: '',
      id:'',
      showPopVisible: true,
      type: 'question',
      callbackUrl: '',
      urlParams: '',
      registParams: '',
      loginResCode:'', //微信code
      questionnaireName:'',//问卷名称
    }
  },
  onLoad(option) {
    this.id = option.id
    this.questionnaireName =option.questionnaireName
    this.init()
  },
  //分享朋友
  onShareAppMessage(res) {
    if (res.from === 'button') { // 来自页面内分享按钮
      console.log(res.target)
    }
    return {
      title: this.questionnaireName,
      imageUrl: `${this.vuex_imgPath}/xfs-520x416.png`,
      path: `/myAccount/questionSurvey/questionnaireSurvey?id=${this.id}&questionnaireName=${this.questionnaireName}`
    }
  },
   methods: {
    closePop(type,agree,mobilePhone) {
      const callbackUrl = '/pages/index/index'
      if(type =='currentPage' && agree == 'agree'){
        this.showPopVisible = false
        uni.redirectTo({ url: `/myAccount/questionSurvey/webview?id=${this.id}&mobilePhone=${mobilePhone}&questionnaireName=${this.questionnaireName}` }) //问卷h5
      }else{
        this.showPopVisible = false
        uni.reLaunch({ url: callbackUrl })
      }
    },
  init(){
    const provider = this.vuex_provider;
      getAuthCode(provider, (loginRes) => {
        if (loginRes.code) {
          console.log('微信code',loginRes)
          this.$u.vuex('vuex_login_code', loginRes.code)
        }
      })
  },
   }
   
}
</script>

<style scoped>

</style>
